/*
 * Created on 08/27/2011 - 2:34 PM
 */
package sembr.geometry.shapes;

import importadorDXF.DxfLWPOLYLINE;
import sembr.geometry.interfacing.ShapeBase;

/**
 *
 * @author adriano
 * 
 * LWPolylineCollector is a collection of LWPolyline DXF AutoCAD representation.
 * This representation of polyline is essentially 2 dimension.
 */
public class LWPolylineCollector extends ShapeBase<DxfLWPOLYLINE>
{
    public LWPolylineCollector()
    {}
    
    public double[][] getVerticesCoordenatesAt(int index)
    {
        int nrOfVertices = getNumberOfVerticesAt(index);
        double[][] vertices = new double[nrOfVertices][2];               
        
        for (int i = 0; i < nrOfVertices; i++)
        {
            vertices[i][0] = getCurrentElement(index).getVertices()[i].getX();
            vertices[i][1] = getCurrentElement(index).getVertices()[i].getY();
        }
        
        return vertices;
    }   
    
    public int getNumberOfVerticesAt(int index)
    {
        return getCurrentElement(index).getVertices().length;
    }
    
    public boolean isClosed(int index)
    {       
        if (getCurrentElement(index).getType() == 1)
            return true;
        else
            return false;
    }
}
